#include "../client/rpc_client.hpp"
#include <thread>
#include <chrono>

void callback(const std::string &key, const std::string &msg)
{
    ILOG("%s 主题收到推送过来的消息：%s", key.c_str(), msg.c_str());
}
int main()
{
    // 1.实例化客户端对象
    auto client = std::make_shared<bitrpc::client::TopicClient>("127.0.0.1", 7070);

    // 2.创建主题
    std::string subject = "hello";
    bool ret = client->create(subject);
    if (ret == false)
    {
        ELOG("主题创建失败");
        return 1;
    }

    // 3.订阅主题
    client->subscribe(subject, callback);
    std::this_thread::sleep_for(std::chrono::seconds(100)); // 只使当前线程休眠，跨平台性强
    client->ShutDown();
    return 0;
}